package cn.gson.springmvc.model.pojos;

import javax.persistence.*;
import java.sql.Date;
import java.util.Objects;

@Entity
public class Hospitalization {
    private int hospitalizationId;
    private Date hospitalizationTime;
    private String hospitalizationMes;
    private Integer hospitalizationState;
    private Patient patientByPatientId;
    private User userByUserId;

    @Id
    @Column(name = "hospitalization_id", nullable = false)
    public int getHospitalizationId() {
        return hospitalizationId;
    }

    public void setHospitalizationId(int hospitalizationId) {
        this.hospitalizationId = hospitalizationId;
    }

    @Basic
    @Column(name = "hospitalization_time", nullable = true)
    public Date getHospitalizationTime() {
        return hospitalizationTime;
    }

    public void setHospitalizationTime(Date hospitalizationTime) {
        this.hospitalizationTime = hospitalizationTime;
    }

    @Basic
    @Column(name = "hospitalization_mes", nullable = true, length = 100)
    public String getHospitalizationMes() {
        return hospitalizationMes;
    }

    public void setHospitalizationMes(String hospitalizationMes) {
        this.hospitalizationMes = hospitalizationMes;
    }

    @Basic
    @Column(name = "hospitalization_state", nullable = true)
    public Integer getHospitalizationState() {
        return hospitalizationState;
    }

    public void setHospitalizationState(Integer hospitalizationState) {
        this.hospitalizationState = hospitalizationState;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Hospitalization that = (Hospitalization) o;
        return hospitalizationId == that.hospitalizationId &&
                Objects.equals(hospitalizationTime, that.hospitalizationTime) &&
                Objects.equals(hospitalizationMes, that.hospitalizationMes) &&
                Objects.equals(hospitalizationState, that.hospitalizationState);
    }

    @Override
    public int hashCode() {
        return Objects.hash(hospitalizationId, hospitalizationTime, hospitalizationMes, hospitalizationState);
    }

    @ManyToOne
    @JoinColumn(name = "patient_id", referencedColumnName = "patient_id")
    public Patient getPatientByPatientId() {
        return patientByPatientId;
    }

    public void setPatientByPatientId(Patient patientByPatientId) {
        this.patientByPatientId = patientByPatientId;
    }

    @ManyToOne
    @JoinColumn(name = "user_id", referencedColumnName = "user_id")
    public User getUserByUserId() {
        return userByUserId;
    }

    public void setUserByUserId(User userByUserId) {
        this.userByUserId = userByUserId;
    }
}
